<?php
/**
 * Created by PhpStorm.
 * User: work
 * Date: 18-8-4
 * Time: 下午3:52
 */

namespace PddWechat\Library;


class ImageLibrary
{

    public static function mergeQr($bkImagePath, $qrImagePath, $newPath) {

        $bigImg = imagecreatefromstring(file_get_contents($bkImagePath));
        $qCodeImg = imagecreatefromstring(file_get_contents($qrImagePath));

        list($bkWidth, $bkHight, $bkType) = getimagesize($bkImagePath);
        list($qCodeWidth, $qCodeHight, $qCodeType) = getimagesize($qrImagePath);

        $left = ($bkWidth- $qCodeWidth)/2;
        $heigh = ($bkHight - $qCodeHight) - 90;
        imagecopymerge($bigImg, $qCodeImg, $left, $heigh, 0, 0, $qCodeWidth, $qCodeHight, 100);
        imagejpeg($bigImg,$newPath);
    }

}